package com.x.Part7_枚举类;

import javax.swing.*;

/**
 * ClassName: SeasonTest
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.03.07 21:26
 */
public class SeasonTest {
    public static void main(String[] args) {
        System.out.println(Season.SPRING.getSeasonDesc());
        System.out.println(Season.SPRING.getSeasonName());
        System.out.println(Season.SUMMER.toString());
    }

}

//jdk5.0之前的枚举类
class Season{

    //1、声明当前类实例对象的变量
    //final修饰的变量必须显式赋值
    private final String seasonName;
    private final String seasonDesc;


    //2、私有化构造器
    private Season(String seasonName, String seasonDesc){
        this.seasonDesc=seasonDesc;
        this.seasonName=seasonName;
    }

    //2、提供get方法


    public String getSeasonName() {
        return seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }

    @Override
    public String toString() {
        return "Season{" +
                "seasonName='" + seasonName + '\'' +
                ", seasonDesc='" + seasonDesc + '\'' +
                '}';
    }

    //4、创建当前类的实例
    //用类名去调对象，static修饰
    //对象的属性只能用，不能改，final修饰
    //所以是全局常量
    public static final Season SPRING = new Season("春天","立春");
    public static final Season SUMMER = new Season("夏天","夏至");
    public static final Season FALL  = new Season("秋天","立秋");
    public static final Season WINTER = new Season("冬天","冬至");
}